package com.caigou.controller;

import com.caigou.bean.cms.param.GenerateYctParam;
import com.caigou.service.GenerateYctService;
import com.caigou.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/generate")
public class GenerateYctController {



    @Resource
    private GenerateYctService generateYctService;


    /**
     * 生成二维码接口
     * @param generateYctParam
     * @return
     */
    @PostMapping("/code")
    public Result code(@RequestBody GenerateYctParam generateYctParam) throws Exception {
        String code = generateYctService.generateYctCode(generateYctParam.getCourseId());
        if(code==null||code.equals("")){
            return Result.error("生成二维码失败","生成二维码失败");
        }
        return  Result.success(code);
    }

    /**
     * 生成易采通中易考通首页二维码接口
     * @return
     * @throws Exception
     */
    @PostMapping("/yktHomeCode")
    public Result yktHomeCode() throws Exception {
        String code = generateYctService.generateYktHomeCodeInYct();
        if(code==null||code.equals("")){
            return Result.error("生成易采通中易考通首页二维码失败","生成易采通中易考通首页二维码失败");
        }
        return  Result.success(code);
    }

}